import DataSourceInfoVO from "@/domain/vo/DataSourceInfoVO";

/**
 * 新增、修改数据源BO
 */
export default class DataSourceInfoFormBO {
    /**
     * 数据库类型(1.mysql)
     */
    databaseType: number | undefined;

    /**
     * 连接地址
     */
    host: string | undefined;
    /**
     * id
     */
    id: string | undefined;
    /**
     * 密码
     */
    password: string;
    /**
     * 连接端口
     */
    port: string | undefined;
    /**
     * 连接库名
     */
    schemaName: string | undefined;
    /**
     * 用户名
     */
    username: string | undefined;

    public coverFormDataSourceInfoVO(dataSourceInfoVO: DataSourceInfoVO) {
        this.id = dataSourceInfoVO.id;
        this.host = dataSourceInfoVO.host;
        this.databaseType = dataSourceInfoVO.databaseType;
        this.port = dataSourceInfoVO.port;
        this.schemaName = dataSourceInfoVO.schemaName;
        this.username = dataSourceInfoVO.username;
        this.password = "";
    }

    public static createFormDataSourceInfoVO(dataSourceInfoVO: DataSourceInfoVO): DataSourceInfoFormBO {
        let vo = new DataSourceInfoFormBO();
        vo.id = dataSourceInfoVO.id;
        vo.host = dataSourceInfoVO.host;
        vo.databaseType = dataSourceInfoVO.databaseType;
        vo.port = dataSourceInfoVO.port;
        vo.schemaName = dataSourceInfoVO.schemaName;
        vo.username = dataSourceInfoVO.username;
        vo.password = "";
        return vo;
    }
}